<template>
  <PageBox :data="dataInfo" @searchBtn="getTbody" :maring="maring" :isRadio="isRadio" :isCheckbox="isCheckbox"
    @tableCheckboxBtn="tableCheckboxBtn" @tableRadioBtn="tableRadioBtn">
    <template #search="{ search }">
      <ElFormItemBox label="报工日期" prop="">
        <ElDaysBox :data="search" :dataName="['createDateBegin', 'createDateEnd']" />
      </ElFormItemBox>
    </template>
    <template #headL>
    </template>
    <template #craftWorkState="{ row }">
      <ElTagBox :data="row.craftWorkState" :options="options.state" />
    </template>
  </PageBox>
  <ElPupFormBox :pup="pup">
    <template #default="{ form }">
      <ElFormItemBox label="报工人员" prop="WorkPerson">
        <ElSelectBox :data="form" dataName="WorkPerson" :options="options.personnel" />
      </ElFormItemBox>
      <ElFormItemBox label="报工设备" prop="MachineName">
        <ElSelectBox :data="form" dataName="MachineName" :options="options.machine" valueName="label" />
      </ElFormItemBox>
      <ElFormItemBox label="开始时间" prop="StartTime">
        <ElDayTimeBox :data="form" dataName="StartTime" />
      </ElFormItemBox>
      <ElFormItemBox label="结束时间" prop="EndTime">
        <ElDayTimeBox :data="form" dataName="EndTime" />
      </ElFormItemBox>
    </template>
  </ElPupFormBox>
</template>
<script setup lang="ts">
const { proxy } = getCurrentInstance() as any;
import './pageCss.scss'; // 引入样式
import { useListComponent } from './pageTs'; // 引入逻辑
const props = withDefaults(
  defineProps<{
    isRadio?: boolean; //单选
    isCheckbox?: boolean; //多选
    maring?: number; //多选
  }>(),
  {
  },
);
//弹窗-数据
const pup: any = reactive({
  state: false,
  typeName: 0,
  title: `打印日报表条件`,
  width: 600,
  height: 'auto',
  form: {
    WorkPerson: "",//人员名称
    MachineName: "",//设备名称
    StartTime: "",//开始时间
    EndTime: "",//结束时间
  },
  btns: [
    {
      title: '打印',
      type: 'primary',
      click: (pup: any) => {
        proxy.$DownLoadTemp(
          {
            templateTypeCode: 'MBLX0017', //	模板类型编号
            customerCode: '', //	客户编号
            condition: pup.form, //
          },
          1,
          dataInfo
        );
        pup.state
      }
    }
  ]
});
const emit = defineEmits<{
  //fn为父组件引入子组件是定义的子组件事件属性，可随意定义
  (event: 'tableRadioBtn', row: any): void;
  (event: 'tableCheckboxBtn', arr: any): void;
}>();
//多选数据
const tableCheckboxBtn = (arr: any) => {
  emit('tableCheckboxBtn', arr);
};
//单选数据
const tableRadioBtn = (row: any) => {
  emit('tableRadioBtn', row);
};
import { getPersonnel, getMachine } from '@/utils/optionsArr.ts';
// 组件挂载后执行
onMounted(() => {
  getTbody();
  getMachine(options, 'machine')//获取设备
  getPersonnel(options, 'personnel') //获取所有员工
});
const { dataInfo, getTbody, options } = useListComponent({
  ...props,
  pup: pup,
});
</script>
